#!/usr/bin/env python3
"""
脚本名称：ch17_exe.py
功能描述： 演示更多文件操作，将文件1中的内容写入至文件2
作者：Gavin
创建日期：2022-05-06
版本：1.0
依赖库：无
使用方法： python ch17_exe.py test.txt test2.txt
"""

from sys import argv
from os.path import exists

script, from_file, to_file = argv

print("Copying from %s to %s" % (from_file, to_file))
# we could do these two on one line too, how?
in_file = open(from_file)
indata = in_file.read()

print("The input file is %d bytes long" % len(indata))
print("Does the output file exist? %r" % exists(to_file))
print("Ready, hit Enter to continue, CTRL-C to abort.")

input()
out_file = open(to_file, 'w')
out_file.write(indata)

print("Alright, all done.")
out_file.close()
in_file.close()
